#include <bits/stdc++.h>
using namespace std;
class Solution {
    int robRange(vector<int> &nums, int l, int r) {
        int dp[2] = { 0,nums[l] };
        for (int i = l + 1; i <= r; ++i) {
            int t = dp[0];
            dp[0] = max(dp[0], dp[1]);
            dp[1] = t + nums[i];
        }
        return max(dp[0], dp[1]);
    }
public:
    int rob(vector<int> &nums) {
        int n = nums.size();
        if (n <= 2)return max(nums[0], nums[n - 1]);
        return max(robRange(nums, 1, n - 1), robRange(nums, 0, n - 2));
    }
};
int main() {
    string line;
    getline(cin, line);
    stringstream readed(line);
    vector<int> nums;
    int num;
    while (readed >> num) {
        nums.push_back(num);
    }
    cout << Solution().rob(nums) << endl;
}